const mongoose = require('mongoose')
const {formatDate} = require('../utils/utils')

const schema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
  },
  phone: {
    type: String,
    required: true,
  },
  resource:{
    type: String,
    required: true,
  },
  isDispose:{
    type: Boolean,
    required: true,
    default: false
  },
  //更新日期
  date: {
    type: mongoose.SchemaTypes.Date,
    default: Date.now,
    get(val) {
      return formatDate(new Date(val), 'yyyy年MM月dd日 hh:mm:ss')
    }
  }
})

module.exports = mongoose.model('Application', schema)
